<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/10/9
 * Time: 18:38
 */

class Circe
{
    private $r ;
  final  function __construct()
    {
    }
    public function __call($methodname,$args)
    {
        die("你所调用的方法:".$methodname."不存在");
    }
    public function __clone()
    {
        $this->r=10;
    }
    public  function __toString()
    {
        return "Circe.r=".$this->r;
        // TODO: Implement __toString() method.
    }

    public function __set($name,$value)
    {
        if($name=='r' && $value<=0)
        {
            $this->r=0;
        }
        else {
            $this->$name = $value;
        }
    }
    public  function __get($value)
    {
        echo $value;
        $this->r=$value;
    }
    public function say()
    {
        echo $this->r*3.14*$this->r; //aa
    }
}

$a = new Circe();
$a->r=5;
$d=$a;
$str=serialize($a);
echo "转义序列化".$str."<br/>";
$f=unserialize($str);
echo "还原序列化".$f."<br/>";
var_dump($f)."<br/>";
echo "魔术方法.toString:";
echo $d;
echo "<br/>";
echo "以下是上一个内容测试";

$aa=clone $a;
var_dump($a);
var_dump($aa);
echo "<br/>";
echo "以下是魔术方法call()的使用";
echo "<br/>";
$e=$d->p();
 class Rectangle  extends shape
{
    private $width,$height;
    function __construct()
    {
       // $this->width=$width;
        //$this->height=$height;
    }
    public function getObj()
    {
          return new Rectangle();
    }
    public  function say()
    {
        echo $this->width.$this->height;
    }

}
$a= Rectangle::getObj();
 $b=Rectangle::getObj();
 class shape
{
    public function say()
    {

    }
    public static function getPi()
    {
        return 3.14;
    }

}
echo shape::getPi();
